//
//  JANewsHeadCell.m
//  网易新闻
//
//  Created by Arvin on 17/3/19.
//  Copyright © 2017年 Arvin. All rights reserved.
//

#import "JANewsHeadCell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>

@implementation JANewsHeadCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
    }
    
    return self;
}

-(void)setupUI{
    
    
    //1.创建并添加子控件
    
    //图片
    _newsImage = [[UIImageView alloc]init];
    [self.contentView addSubview:_newsImage];
    
    //标题
    _newsTitle = [[UILabel alloc]init];
    [self.contentView addSubview:_newsTitle];
    _newsTitle.font = [UIFont systemFontOfSize:18];
    _newsTitle.textColor = [UIColor colorWithWhite:0.8 alpha:0.8];
    _newsTitle.numberOfLines = 0;
    
    
    
    //自动布局
    [_newsImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(126);
        
    }];
    
    [_newsTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(_newsImage);
        make.height.mas_equalTo(28);
    }];
    
}

-(void)setModel:(JANewsModel *)model{
    _model = model;
    [_newsImage sd_setImageWithURL:[NSURL URLWithString:_model.imgsrc]];
    _newsTitle.text = model.title;
    
    
}


@end
